package com.demo.springBoot2.controller;

import com.demo.springBoot2.entity.vo.QuartzSosVO;
import com.demo.springBoot2.music.TtsMusicUtil;
import com.demo.springBoot2.result.Result;
import com.demo.springBoot2.service.IQuartzService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author pl711@qq.com
 * @PackageName springBoot2
 * @Package com.demo.springBoot2.controller
 * @Date 2024/4/16 12:59
 * @Version 1.0
 *   定时任务框架
 */
@Slf4j
@Api(tags = "定时任务")
@RestController
@RequestMapping("quartz")
public class QuartzController {
    @Autowired
    private TtsMusicUtil ttsMusicUtil;
    @Autowired
    private IQuartzService iQuartzService;
    @ApiOperation(value = "文字转语音播放地址")
    @GetMapping("getMusicUrl")
    public Result getMusicUrl(String message){
        String url = ttsMusicUtil.syntheticAudio(message);
        return Result.success(url).msg("音频地址获取成功");
    }
    @PostMapping("/startOrStop")
    public Result startOrStop(@Valid @RequestBody QuartzSosVO quartzSosVO) throws ClassNotFoundException {
        log.info("我进入Controller了");
        iQuartzService.startOrStop(quartzSosVO);
        return Result.success().msg("接口控制任务的开始或停止成功");
    }
}
